﻿
using NUnit.Framework;
using AdventureWorks.DataAccess.Repositories;
using AdventureWorks.Domain;
using NHibernate;
using AdventureWorks.DataAccess.Utils;
using AdventureWorks.DataAccess.Specifications;
using System.Linq;
using NHibernate.Linq;
using AdventureWorks.DataAccess.SearchCriterias;

namespace AdventureWorks.DataAccess.Test.repository
{
    [TestFixture]
    public class SpecialOfferRepositoryTest 
    {
        private NHibernateRepository<SpecialOffer> repository;

        private ISession session;
        


        [SetUp]
        public void Setup()
        {
            var d = SessionManager.SessionFactory.OpenSession();
            repository = new NHibernateRepository<SpecialOffer>(d);
            session = SessionManager.SessionFactory.OpenSession();
        }

        [TearDown]
        public void Teardown()
        {
            //repository = null;
            session.Close();
        }

        [Test]
        public void Should_Query_Existing_data_with_criteria()
        {
            //var list = repository.GetSpecialOffers(session, new SpecialOfferSearchCriteria { Type = "Volume Discount" });
            var d = new SpecialOfferSpecification() { Category = "Customer" };
            var list = repository.Find(d).ToList();
            Assert.AreEqual(2, list.Count);
        }


    }
}
